(* list.pp *)

unit list;

interface

uses nodes;

var
   head	: link;

procedure NodeIns(a : node; p : link); (* wstawianie po wezle wskazywanym przez p*)
procedure CardSh(k: integer);

implementation

procedure NodeIns(a : node; p : link);
var
   q : link;
begin
   new(q); 
   if p = nil then
   begin (* wstawianie do listy pustej lub po head *)
      head := q;
      head^.item := a.item;
      head^.next := nil;
   end
   else
   begin
      head := q;
      head^.item := a.item;
      head^.next := p;
   end;
end; { NodeIns }

procedure CardSh(k: integer);
var
   i	   : integer;
   t,u,w,s : link;
begin	   
   t := head; 
   u := head;
   for i := 1 to k do
      t := t^.next;
   w := t^.next;
   while w <> nil do
   begin
      if w^.next = nil then s := w;  
      w := w^.next;  
   end;	       
   head := t^.next;
   s^.next := u;
   t^.next := nil;
end;

end.
